import gtk

from widgetOrganizer import WidgetOrganizer
from input import Input
from output import Output


class Cell(WidgetOrganizer, gtk.Frame):
    '''
    A Cell is a container for one Input and one Output. 
    '''
    
    def __init__(self, ancestor, DOM=None):
        gtk.Frame.__init__(self)
        WidgetOrganizer.__init__(self, 'Cell', ancestor)
        
        self.set_shadow_type(gtk.SHADOW_NONE)     
        
        self.xmlTag = 'cell'
        
        #create CellVBox-object
        self._createVBox(DOM)
        
        
    def _createVBox(self, DOM):
        self.VBox = gtk.VBox()
        self.VBox.show()
        self.add(self.VBox)
        
        if DOM:
            inputDOM = DOM.getElementsByTagName('input')[0]
            outputDOM = DOM.getElementsByTagName('output')[0]
        else:
            inputDOM = None
            outputDOM = None
        
        #create subwidgets
        input = Input(self, DOM=inputDOM)
        self.addChild(input)
        self.VBox.pack_start(input, expand=False)
        
        output = Output(self, DOM=outputDOM)
        self.addChild(output,1)
        self.VBox.pack_start(output, expand=False)
    